package com.ybxx.base.model;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.httpclient.util.DateParseException;
import org.apache.commons.lang.StringUtils;

import com.ybxx.config.model.HouseType;
import com.ybxx.core.model.BaseModel;
import com.ybxx.core.util.DateUtil;

@Entity
@Table(name="tbl_base_room_info")
public class RoomInfo extends BaseModel {
	@Id
	private String icode;
	@ManyToOne(targetEntity=Room.class,fetch=FetchType.LAZY)
	@JoinColumn(name="rid",referencedColumnName="rid") 
	private Room room;
	@ManyToOne(targetEntity=HouseType.class,fetch=FetchType.LAZY)
	@JoinColumn(name="hcode",referencedColumnName="hcode") 
	private HouseType houseType;
	private String coveredarea;
	private String ucarea;
	private String heatingarea;
	private String filearea;
	private String ctime;
	private String cost;
	private String content;
	private String kitchen;
	private String toilet;
	@Transient
	private boolean kitchensign;
	@Transient
	private boolean toiletsign;
	public String getIcode() {
		return icode;
	}
	public void setIcode(String icode) {
		this.icode = icode;
	}
	public Room getRoom() {
		return room;
	}
	public void setRoom(Room room) {
		this.room = room;
	}
	public HouseType getHouseType() {
		return houseType;
	}
	public void setHouseType(HouseType houseType) {
		this.houseType = houseType;
	}
	public String getCoveredarea() {
		return coveredarea;
	}
	public void setCoveredarea(String coveredarea) {
		this.coveredarea = coveredarea;
	}
	public String getUcarea() {
		return ucarea;
	}
	public void setUcarea(String ucarea) {
		this.ucarea = ucarea;
	}
	public String getHeatingarea() {
		return heatingarea;
	}
	public void setHeatingarea(String heatingarea) {
		this.heatingarea = heatingarea;
	}
	public String getFilearea() {
		return filearea;
	}
	public void setFilearea(String filearea) {
		this.filearea = filearea;
	}
	public String getCtime() {
		if(StringUtils.isEmpty(ctime)){
			ctime=DateUtil.formatDate(DateUtil.parseDate(ctime));
		}
		return ctime;
	}
	public void setCtime(String ctime) {
		if(StringUtils.isNotEmpty(ctime)){
			this.ctime = ctime;
		}
	}
	public String getCost() {
		return cost;
	}
	public void setCost(String cost) {
		if(StringUtils.isNotEmpty(cost)){
			this.cost = cost;
		}
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getKitchen() {
		return kitchen;
	}
	public void setKitchen(String kitchen) {
		this.kitchen = kitchen;
	}
	public String getToilet() {
		return toilet;
	}
	public void setToilet(String toilet) {
		this.toilet = toilet;
	}
	
	public boolean isKitchensign() {
		if("1".equals(kitchen)){
			kitchensign=false;
		}else{
			kitchensign=true;
		}
		return kitchensign;
	}
	public boolean isToiletsign() {
		if("1".equals(toilet)){
			toiletsign=false;
		}else{
			toiletsign=true;
		}
		return toiletsign;
	}
}
